import 'package:answer_demo/answer/ApplicationMain.dart';
import 'package:answer_demo/answer/JudgeMain.dart';
import 'package:answer_demo/answer/MulitpleMain.dart';
import 'package:answer_demo/answer/SingleMain.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

//表格组件
void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    //debugPaintSizeEnabled = true;
    return MaterialApp(
      title: 'Scaffold Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      routes: {
        "single": (_) => SingleMain(),
        "multiple": (_) => MultipleMain(),
        "judge": (_) => JudgeMain(),
        "application": (_) => ApplicationMain(),
      },
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage>
    with SingleTickerProviderStateMixin {
  //AnimationController _controller;
  int _selectedIndex = 1;

  @override
  void initState() {
    super.initState();
    //_controller = AnimationController(vsync: this);
  }

  @override
  void dispose() {
    //_controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        //导航栏
        title: Text("App Name"),
      ),
      bottomNavigationBar: BottomNavigationBar(
        // 底部导航
        items: <BottomNavigationBarItem>[
          BottomNavigationBarItem(
              icon: Icon(
                Icons.home,
                color: Colors.blue,
              ),
              label: 'Home'),
          BottomNavigationBarItem(
              icon: Icon(
                Icons.settings,
                color: Colors.blue,
              ),
              label: 'Settings'),
        ],
        currentIndex: _selectedIndex,
        fixedColor: Colors.blue,
        onTap: _onItemTapped,
      ),
      body: Center(
        child: ListView(
          children: [
            RaisedButton(
              onPressed: () {
                Navigator.pushNamed(context, "single");
              },
              child: Text(
                "单选题",
                style: TextStyle(fontSize: 36),
              ),
            ),
            RaisedButton(
              onPressed: () {
                Navigator.pushNamed(context, "multiple");
              },
              child: Text(
                "多选题",
                style: TextStyle(fontSize: 36),
              ),
            ),
            RaisedButton(
              onPressed: () {
                Navigator.pushNamed(context, "judge");
              },
              child: Text(
                "判断题题",
                style: TextStyle(fontSize: 36),
              ),
            ),
            RaisedButton(
              onPressed: () {
                Navigator.pushNamed(context, "application");
              },
              child: Text(
                "应用题",
                style: TextStyle(fontSize: 36),
              ),
            ),
          ],
        ),
      ),
    );
  }

  void _onItemTapped(int index) {
    setState(() {
      print("_onItemTapped $index");
      _selectedIndex = index;
    });
  }
}
